<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	  xmlns:c="http://java.sun.com/jsp/jstl/core"
	  xmlns:f="http://java.sun.com/jsf/core"
	  xmlns:h="http://java.sun.com/jsf/html"
	  xmlns:ui="http://java.sun.com/jsf/facelets">
	<ui:composition template="../template.xhtml">
		<ui:define name="content">
			<h:form>
				<table>
					<caption>Options</caption>
					<tr>
						<th>Name</th>
						<td>
							<h:inputText value="#{searchBlog.options.name}"/>						
						</td>
					</tr>
					<tr>
						<th>Description</th>
						<td>
							<h:inputText value="#{searchBlog.options.description}"/>
						</td>
					</tr>
					<tr>
						<th></th>
						<td>
							<h:commandButton action="#{searchBlog.searchBlog}"
											 value="Search"/>
						</td>
					</tr>			
				</table>
				<h:messages/>
			</h:form>		
			
			<c:if test="#{searchBlog.pages != null and searchBlog.pages.size() > 0}">
				<h:form>
					<h:dataTable value="#{searchBlog.result}"
								 var="blog">
						<f:facet name="caption">Result</f:facet>					 
								 
						<h:column>
							<f:facet name="header">Name</f:facet>
							<h:commandLink action="#{editBlog.initialize(blog)}" value="#{blog.name}"/>								
						</h:column>
						
						<h:column>
							<f:facet name="header">Creation Date</f:facet>
							<h:outputText value="#{blog.creationDate}">
								<f:convertDateTime pattern="dd/MM/yyyy"/>
							</h:outputText>											
						</h:column>
						
						<h:column>
							<f:facet name="header"></f:facet>
							<h:commandLink action="#{deleteBlog.initialize(blog)}" value="Delete"/>
						</h:column>				
					</h:dataTable>
		
					<div class="pagination">
						<h:commandButton action="#{searchBlog.goToFirst()}"
										 disabled="#{searchBlog.page == 1}"
						   			     value="First">
							<f:ajax render="@form"/>
						</h:commandButton>
						<h:commandButton action="#{searchBlog.goToPrevious()}"
										 disabled="#{searchBlog.page == 1}"
						   			     value="Previous">	
							<f:ajax render="@form"/>
						</h:commandButton>   			     
						<ui:repeat value="#{searchBlog.pages}"
								   var="page">
							<h:commandLink action="#{searchBlog.goTo(page)}"
										   disabled="#{page == searchBlog.page}"
										   value="#{page}">
								<f:ajax render="@form"/>
							</h:commandLink>
						</ui:repeat>			
						<h:commandButton action="#{searchBlog.goToNext()}"
										 disabled="#{searchBlog.page == searchBlog.pages.size()}"
						   			     value="Next"/>					   	
						<h:commandButton action="#{searchBlog.goToLast()}"
										 disabled="#{searchBlog.page == searchBlog.pages.size()}"
						   			     value="Last"/>			   			   										
					</div>
				</h:form>
			</c:if>						
		</ui:define>
	</ui:composition>
</html>
